package com.mengjiahui.auduoplayer.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.mengjiahui.auduoplayer.adapter.PlayMusicFragmentPagerAdapter;
import com.mengjiahui.auduoplayer.fragment.PlayMusicImgFragment;
import com.mengjiahui.auduoplayer.fragment.PlayMusicWordFragment;
import com.mengjiahui.auduoplayer.R;
import com.mengjiahui.auduoplayer.bean.Music;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Meng
 * @data 2020/5/10
 */
public class PlayMusicActivity extends AppCompatActivity {
    private TextView textView;
    private ViewPager viewPager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_music);
        Intent intent=getIntent();
        Bundle bundle=intent.getExtras();
        Music music=(Music)bundle.getSerializable("music");
        textView=findViewById(R.id.textViewPlayMusicName);
        textView.setText(music.getAuthor()+"\n"+music.getMusicName());
        List<Fragment> list =new ArrayList<>();
        list.add(new PlayMusicImgFragment());
        list.add(new PlayMusicWordFragment());
        PlayMusicFragmentPagerAdapter playMusicFragmentPagerAdapter=new PlayMusicFragmentPagerAdapter(getSupportFragmentManager(),list);
        viewPager=findViewById(R.id.viewPagerPlayMusic);
        viewPager.setAdapter(playMusicFragmentPagerAdapter);
        viewPager.setCurrentItem(0);
    }
}
